import Vue from 'vue'
import Router from 'vue-router'
Vue.use(Router)

export const constantRoutes = [
    {
        path: '/',
        redirect: '/login'
    },
    {
        path: '/login',
        component: () => import('@/views/login')
    },
    {
        path: '/home',
        component:()=>import('@/views/home')
    },
    {
        path: '/enter',
        component:()=>import('@/views/enter')
    },
    {
        path: '/model',
        component:()=>import('@/views/model')
    },
    {
        path: '/overall',
        component:()=>import('@/views/overall')
    },
    {
        path: '/agriculture',
        component:()=>import('@/views/agriculture')
    },
    {
        path: '/industry',
        component:()=>import('@/views/industry')
    },
    {
        path: '/service',
        component:()=>import('@/views/service')
    },
    {
        path: '/society',
        component:()=>import('@/views/society')
    },
    {
        path: '/other',
        component:()=>import('@/views/other')
    },
    {
        path: '/404',
        component: () => import('@/views/error-page/404'),
    },
    {
        path: '/401',
        component: () => import('@/views/error-page/401'),
    },
    { path: '*', redirect: '/404', hidden: true }
]

export const asyncRoutes = [

]

const createRouter = () => new Router({
    // mode: 'history', // require service support
    //mode: 'history',
    scrollBehavior: () => ({ y: 0 }),
    routes: constantRoutes
})

const router = createRouter()

export function resetRouter() {
    const newRouter = createRouter()
    router.matcher = newRouter.matcher // reset router
}

export default router
